package com.qs.javame.thread.threadlocal;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class TestDemo2 {

    private static ThreadLocal<String> threadLocal = new ThreadLocal<>();

    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(5);
        for (int i = 0; i < 100; i++) {
            executorService.execute(new Task());
        }

        executorService.shutdown();
    }
}


class Task implements Runnable {

    private int sum = 0;

    public void add() {
        sum = sum + 1;
    }

    @Override
    public void run() {
        for (int i = 0; i < 1000; i++) {
            add();
        }

        System.out.println(Thread.currentThread().getName() + "-->>sum=" + sum);
    }
}